package com.xy.entity;

import lombok.Getter;
import lombok.Setter;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.UUID;
import jakarta.persistence.*;
import org.hibernate.annotations.UuidGenerator;

/**
 * .
 * <p>
 *
 * @author <a href="mailto:shunshun.lss@alibaba-inc.com">shunshun.lss</a>
 * @version 1.0.0
 * @since 2024-10-14
 */
@Setter
@Getter
@Entity
@Table(name = "user_profiles")
public class UserProfilesEntity {

    @Id
    @UuidGenerator
    @Column(name = "id")
    UUID id;

    @Column(name = "first_name")
    String firstName;

    @Column(name = "last_name")
    String lastName;

    @Column(name = "email")
    String email;

    @Column(name = "birth_date")
    Date birthDate;

    @Column(name = "sex")
    int sex;

    @Column(name = "create_by")
    UUID createBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_date")
    Timestamp createDate;

    @Column(name = "update_by")
    UUID updateBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_date")
    Timestamp updateDate;

    @PrePersist
    protected void onCreate() {
        createDate = Timestamp.valueOf(LocalDateTime.now());
    }

    @PreUpdate
    protected void onUpdate() {
        updateDate = Timestamp.valueOf(LocalDateTime.now());
    }
}